package com.cqqs.common.exception;

import com.cqqs.common.enums.error.BusinessError;

/**
 * @ClassName: BusinessException
 * @Description: 业务异常类
 * @Author: mjxie
 * @Date:9/15/21 1:32 PM
 */
public class BusinessException extends RuntimeException implements BusinessError {
    private final int code;

    private final String msg;

    private final String data;


    public BusinessException(BusinessError error, String data) {

        super(error.getMsg());
        this.code = error.getCode();
        this.msg = error.getMsg();
        this.data = data;
    }

    public BusinessException(BusinessError error) {
        super(error.getMsg());
        this.code = error.getCode();
        this.msg = error.getMsg();
        this.data = error.getData();
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.msg;
    }

    @Override
    public String getData() {
        return this.data;
    }
}